#include "audio_play.h"
#include "audio_decode.h"

extern "C" {
#include <sdl/SDL.h>
}

class AudioPlayImpl
        : public AudioPlay {
public:
    AudioPlayImpl();
    ~AudioPlayImpl();
public:
    virtual bool Open(const std::string &file) override;
    virtual void Close() override;
    virtual void Play(bool loop) override;
    virtual void Stop() override;
    virtual void Pause() override;
    virtual void Continue() override;
    virtual void Seek(double pos) override;
    virtual double Duration() override;
protected:
    std::shared_ptr<AudioDecode> m_decode;
};
//----------------------------//
std::shared_ptr<AudioPlay> AudioPlay::NewInterface() {
    return std::shared_ptr<AudioPlay>(new AudioPlayImpl);
}

//----------------------------//
AudioPlayImpl::AudioPlayImpl()
        : m_decode(nullptr) {
    m_decode = AudioDecode::NewInterface();
    SDL_assert(m_decode == nullptr);
    SDL_Init(SDL_INIT_EVERYTHING);
}

AudioPlayImpl::~AudioPlayImpl() {
    SDL_Quit();
}

bool AudioPlayImpl::Open(const std::string &file) {
    return m_decode->Open(file);
}

void AudioPlayImpl::Close() {
    m_decode->Close();
}

void AudioPlayImpl::Play(bool loop) {

}

void AudioPlayImpl::Stop() {

}

void AudioPlayImpl::Pause() {

}

void AudioPlayImpl::Continue() {

}

void AudioPlayImpl::Seek(double pos) {

}

double AudioPlayImpl::Duration() {
    return 0.0f;
}

//----------------------------//